/*---------------------------------------------[ 正则 ]---------------------------------------------*/
var num_check = /^[1-9]\d*$/,  // 正整数验证
    num_check_1 = /^\d*$/,  // 正整数验证
    //money_check_1 = /^[1-9]\d{0,6}\.?[0-9]{0,2}$/,  // 金额验证
    money_check_1 = /^[1-9]\d{0,6}(\.[0-9]{2}|\.[0-9]|\.|)$/,  // 金额验证,商标注册底单商品金额验证js
    money_check = /^[1-9][0-9]{0,6}(\.[0-9]{2}|\.[0-9]|)$/,  // 金额验证
    blank_contract_money_check = /^[1-9]\d{0,7}(.00|.0|)$/,  // 空白合同金额验证
    html_check = /.*[<'">].*/,   //不允许输入小引号
    html_check_1 = /.*[<">].*/,   //允许输入小引号
    Num_check = /^([+-]?)\d*\.?\d+$/;
    MobileNum = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;

/** 验证数据 返回true则通过 */
function verifyData(data, min, max) {
    if (null == data || undefined == data || data.length < min || data.length > max) {
        return false;
    }
    return true;
}

/**
 * 判断是否为空
 * @param val
 * @returns {boolean}
 */
function checkIsEmpty(val) {
    if (null !== val && '' !== val && undefined !== val && "null" !== val) {
        return false;
    } else {
        return true;
    }
}

/*--------------------------------------[ Add by yan.x 2018/11/2 begin ]------------------------------------*/
/**
 * 去掉字符串头尾空格
 * @param str
 * @returns {string|void|XML|*}
 */
function valueTrim(str) {
    return str.replace(/(^\s*)|(\s*$)/g, "");
}

//过滤HTML标签
function removeHTMLTag(str) {
    str = str.replace(/<\/?[^>]*>/g, ''); //去除HTML tag
    str = str.replace(/[ | ]*\n/g, '\n'); //去除行尾空白
    //str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
    str = str.replace(/ /ig, ''); //去掉
    return str;
}

//特殊字符验证，不允许输入小引号
function checkSymbol(value) {
    return html_check.test(value);
}

//验证是否手机号
function isMobelPhone(value) {
    return MobileNum.test(value);
}

//金额验证
function moneyCheck(value) {
    return money_check.test(value)
}

//特殊字符验证，允许输入小引号
function checkSymbolNotQuotes(value) {
    return html_check_1.test(value);
}

/**
 * 判断是否是数字
 * @param numberValue 要验证的数据
 * @returns 匹配返回true 不匹配返回false
 */
function isNumber(numberValue) {
    //定义正则表达式部分
    var reg1 = /^[0-9]{0,}$/;
    var reg2 = /^[1-9]{1}[0-9]{0,}$/;
    //alert(numberValue);
    if (numberValue == null || numberValue.length == 0) {
        return false;
    }
    numberValue = valueTrim(numberValue);
    //判断当数字只有1位时
    if (numberValue.length < 2) {
        return reg1.test(numberValue);
    }
    return reg2.test(numberValue);
}

/**
 * 验证是否图片类型
 * @param val
 * @returns {boolean}
 */
function checkFile(val) {
    if (checkIsEmpty(val)) {
        return false;
    }
    if (!/.(gif|jpg|jpeg|png|pdf|PDF|GIF|JPG|JPEG|PNG)$/.test(val)) {
        return false;
    }
    return true;
}

/**
 * 验证是否图片类型
 * @param val
 * @returns {boolean}
 */
function checkIsImage(val) {
    if (checkIsEmpty(val)) {
        return false;
    }
    if (!/.(gif|jpg|jpeg|png|GIF|JPG|JPEG|PNG)$/.test(val)) {
        return false;
    }
    return true;
}

/**
 * 验证是否图片是否是jpg类型
 * @param val
 * @returns {boolean}
 */
function checkIsJPG(val) {
    if (checkIsEmpty(val)) {
        return false;
    }
    if (!/.(jpg|JPG)$/.test(val)) {
        return false;
    }
    return true;
}

/**
 * 验证是否图片的扩展名是否是jpg类型
 * @param extension 文件的扩展名
 * @returns {boolean}
 */
function checkSuffixIsJPG(extension) {
    if (checkIsEmpty(extension)) {
        return false;
    }
    if (!/(jpg|JPG)$/.test(extension)) {
        return false;
    }
    return true;
}

/**
 * 验证是否图片是否是jpg类型
 * @param val
 * @returns {boolean}
 */
function checkIsJPEG(val) {
    if (checkIsEmpty(val)) {
        return false;
    }
    if (!/.(jpg|JPG|jpeg|JPEG)$/.test(val)) {
        if (!/.(jpg|JPG)$/.test(val)) {
            return false;
        }
        return true;
    }
}

/**
 * 验证是否图片是否是PDF类型
 * @param val
 * @returns {boolean}
 */
function checkIsPDF(val) {
    if (checkIsEmpty(val)) {
        return false;
    }
    if (!/.(pdf|PDF)$/.test(val)) {
        return false;
    }
    return true;
}

/*--------------------------------------[ Add by yan.x 2018/11/2  end  ]------------------------------------*/

/**
 * 正则验证
 * @param reg 正则表达式
 * @param obj
 * @param message 提示的内容
 * @param falg 是否验证空
 * @returns {boolean}
 */
function regCheck(reg, obj, msg, falg) {
    var val = $(obj).val();
    if (falg == false || falg == undefined) {
        if (!reg.test(val)) {
            dgg.dialog.tip(checkIsEmpty(msg) ? '您输入的内容有误' : msg, obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else {
            layer.closeAll("tips");
            return true;
        }
    } else {
        if (checkIsEmpty(val)) {
            dgg.dialog.tip('输入内容不能为空', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else {
            if (!reg.test(val)) {
                dgg.dialog.tip(checkIsEmpty(msg) ? '您输入的内容有误' : msg, obj, {tips: [3, '#000'], time: 3000});
                return false;
            } else {
                layer.closeAll("tips");
                return true;
            }
        }
    }


}

/**
 * 下拉框选择验证
 * @param obj
 * @param tipObj 标签提示位置 select2的下拉框传值参考$(obj).next()  不传默认obj
 * @param msg 提示信息 不传默认 '选择内容不能为空'
 */
function checkDropDownChoice(obj, tipObj, msg) {
    var value = $(obj).find("option:selected").val();//获取下拉列表选中值
    if (checkIsEmpty(value)) {
        dgg.dialog.tip(checkIsEmpty(msg) ? '选择内容不能为空' : msg, checkIsEmpty(tipObj) ? obj : tipObj, {
            tips: [3, '#000'],
            time: 3000
        });
        return false;
    } else {
        layer.closeAll("tips");
        return true;
    }
}

/**
 * input输入框验证
 * @param obj
 * @param msg 提示信息 不传默认 '输入内容不能为空'
 */
function checkInputBox(obj, msg, tipObj) {
    //获取输入框值
    var value = $(obj).val();
    if (checkIsEmpty(value)) {
        dgg.dialog.tip(checkIsEmpty(msg) ? '输入内容不能为空' : msg, checkIsEmpty(tipObj) ? obj : tipObj, {
            tips: [3, '#000'],
            time: 3000
        });
        return false;
    } else {
        layer.closeAll("tips");
        return true;
    }
}

/**
 * 判断浮点型
 * @param obj
 * @param float 小数位数
 * @param falg  是否为空
 * @returns {boolean}
 */
function isFloat(obj, float, falg) {
    var objVal = $(obj).val(),
        objFlat = objVal.indexOf("."),
        isFloat = /^[-\+]?\d+(\.\d+)?$/;
    if (falg == false) {
        if (objVal == "" || objVal == null) {
            layer.closeAll("tips");
            return true;
        } else if (!isFloat.test(objVal)) {
            dgg.dialog.tip('只能输入数字!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else if (float != undefined && objFlat > 0) {
            var flo = objVal.toString().split(".")[1].length
            if (flo > float) {
                dgg.dialog.tip('只能输入小数位' + float + '位以内大于等于0的小数', obj, {tips: [3, '#000'], time: 3000});
                return false;
            } else {
                layer.closeAll("tips");
                return true;
            }
        } else {
            layer.closeAll("tips");
            return true;
        }
    } else {
        if (objVal == "" || objVal == null) {
            dgg.dialog.tip('输入内容不能为空', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else if (!isFloat.test(objVal)) {
            dgg.dialog.tip('只能输入数字!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else if (float != undefined && objFlat > 0) {
            var flo = objVal.toString().split(".")[1].length;
            if (flo > float) {
                dgg.dialog.tip('只能输入小数位' + float + '位以内大于等于0的 小数', obj, {tips: [3, '#000'], time: 3000});
                return false;
            } else {
                layer.closeAll("tips");
                return true;
            }
        } else {
            layer.closeAll("tips");
            return true;
        }
    }

}

/**
 * 判断大于0的浮点型
 * @param obj
 * @param float 小数位数
 * @param falg  是否为空
 * @returns {boolean}
 */
function isFloatGteZero(obj, float, falg) {
    var objVal = $(obj).val(),
        objFlat = objVal.indexOf("."),
        isFloat = /^\d+(\.\d+)?$/;
    if (falg == false) {
        if (objVal == "" || objVal == null) {
            layer.closeAll("tips");
            return true;
        } else if (!isFloat.test(objVal)) {
            dgg.dialog.tip('只能输入大于零的数字!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else if (float != undefined && objFlat > 0) {
            var flo = objVal.toString().split(".")[1].length
            if (flo > float) {
                dgg.dialog.tip('只能输入小数位' + float + '位以内大于等于0的小数', obj, {tips: [3, '#000'], time: 3000});
                return false;
            } else {
                layer.closeAll("tips");
                return true;
            }
        } else {
            layer.closeAll("tips");
            return true;
        }
    } else {
        if (objVal == "" || objVal == null) {
            dgg.dialog.tip('输入内容不能为空', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else if (!isFloat.test(objVal)) {
            dgg.dialog.tip('只能输入大于零的数字!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else if (float != undefined && objFlat > 0) {
            var flo = objVal.toString().split(".")[1].length;
            if (flo > float) {
                dgg.dialog.tip('只能输入小数位' + float + '位以内大于等于0的小数', obj, {tips: [3, '#000'], time: 3000});
                return false;
            } else {
                layer.closeAll("tips");
                return true;
            }
        } else {
            layer.closeAll("tips");
            return true;
        }
    }
}


/**
 * 手机号码验证
 * @param obj
 * @param falg 是否为空
 * @returns {boolean}
 */
function isMobile(obj, falg) {
    var objVal = $(obj).val(),
        MobileNum = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
    if (falg == false || falg == undefined) {
        if (objVal == "" || objVal == null) {
            layer.closeAll("tips");
            return true;
        } else {
            if (!MobileNum.test(objVal)) {
                dgg.dialog.tip('请正确填写手机号码', obj, {tips: [3, '#000'], time: 3000});
                return false;
            } else {
                layer.closeAll("tips");
                return true;
            }
        }
    } else {
        if (objVal == "" || objVal == null) {
            dgg.dialog.tip('输入内容不能为空', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else {
            if (!MobileNum.test(objVal)) {
                dgg.dialog.tip('请正确填写手机号码', obj, {tips: [3, '#000'], time: 3000});
                return false;
            } else {
                layer.closeAll("tips");
                return true;
            }
        }
    }
};

/**
 * 身份证号码
 * @param obj
 * @param falg 是否为空
 * @returns {boolean}
 */
function isIdCardNo(obj, falg) {
    var objVal = $(obj).val();
    var len = objVal.length,
        re;
    var base;
    base = function (obj) {
        if (len == 15) re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{2})(\w)$/);
        else if (len == 18) re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\w)$/);
        else {
            dgg.dialog.tip('请输入正确身份证号码', obj, {tips: [3, '#000'], time: 3000});
            return false;
        }
        var a = objVal.match(re);
        if (a != null) {
            if (len == 15) {
                var D = new Date("19" + a[3] + "/" + a[4] + "/" + a[5]);
                var B = D.getYear() == a[3] && (D.getMonth() + 1) == a[4] && D.getDate() == a[5];
            } else {
                var D = new Date(a[3] + "/" + a[4] + "/" + a[5]);
                var B = D.getFullYear() == a[3] && (D.getMonth() + 1) == a[4] && D.getDate() == a[5];
            }
            if (!B) {
                dgg.dialog.tip('您输入的身份证号出生日期不对', obj, {tips: [3, '#000'], time: 3000});
                return false;
            }
        }
        if (!re.test(objVal)) {
            dgg.dialog.tip('请输入正确身份证号码', obj, {tips: [3, '#000'], time: 3000});
            return false;
        }
        if (re.test(objVal)) {
            layer.closeAll("tips");
            return true;
        }
    };
    if (falg == false || falg == undefined) {
        if (objVal == "" || objVal == null) {
            layer.closeAll("tips");
            return true;
        } else {
            return base(obj);
        }
    } else {
        if (objVal == "" || objVal == null) {
            dgg.dialog.tip('输入内容不能为空', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else {
            return base(obj);
        }
    }

};


//验证微信
function isWx(obj, falg) {
    var objVal = $(obj).val();
    var $obj = $(obj),
        //QQ
        reg1 = /^[1-9]\d{4,12}$/,
        //手机号
        reg2 = /^[1][3,4,5,6,7,8,9][0-9]{9}$/,
        //微信
        reg3 = /^[a-zA-Z][a-zA-Z0-9_-]{5,19}$/,
        //微信号带字母的 6-20
        flag = reg1.test($obj.val()) || reg2.test($obj.val()) || reg3.test($obj.val());

    if (falg == false || falg == undefined) {
        if (objVal == "" || objVal == null) {
            layer.closeAll("tips");
            return true;
        } else {
            if (!flag) { //正则验证不通过，格式不对
                dgg.dialog.tip('微信账号格式不正确', obj, {tips: [3, '#000'], time: 3000});
                return false;
            } else {
                layer.closeAll("tips");
                return true;
            }
        }
    } else {
        if (objVal == "" || objVal == null) {
            dgg.dialog.tip('输入内容不能为空', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else {
            if (!flag) { //正则验证不通过，格式不对
                dgg.dialog.tip('微信账号格式不正确', obj, {tips: [3, '#000'], time: 3000});
                return false;
            } else {
                layer.closeAll("tips");
                return true;
            }
        }
    }
}

/**
 * 约束输入  只能是正整数
 * @param obj
 * @param length 长度
 * @param isZero 是否可用为0
 */
function restrictInputLength(obj, length, isZero) {
    var $obj = obj instanceof jQuery ? obj : $(obj);
    var val = $obj.val();
    if (val) {
        if (!val.replace(/[^\d]/g, '') || val.length > length) {
            DGG.Warning('只能输入' + length + "位的正整数!")
        }
        val = val.replace(/[^\d]/g, '').substr(0, length);
        if (val.length > 1 && val.substr(0, 1) == 0) {
            val = "";
            DGG.Warning('请规范你的输入!');
        }
        if (isZero) {
            if (val == 0) {
                DGG.Warning('只能输入大于0的正整数!');
                val = "";
            }
        }
    }
    $(obj).val(val);
}

/**
 * 约束输入  只能是正整数
 * @param obj
 * @param length 长度
 * @param isZero 是否可用为0
 */
function numberCheck(obj, length, isZero, msg) {
    var objVal = $(obj).val();
    var Number = /^[1-9]\d*$/;
    if (!!isZero) {
        Number = /^\d+$/;
    }
    if (Number.test(objVal) && objVal.length <= length) {
        return true;
    }
    dgg.dialog.warning(msg + '只能输入不大于' + length + '位的正整数!', 2000);
    return false;
}

/**
 * 约束输入  只能是正整数
 * @param obj
 * @param length 长度
 * @param isZero 是否可用为0
 */
function numCheck(obj, length, falg) {
    var objVal = $(obj).val();
    var Number = /^[0-9]\d*$/;
    if (falg == false || falg == undefined) {
        if (objVal == "" || objVal == null) {
            layer.closeAll("tips");
            return true;
        } else {
            if (!Number.test(objVal)) {
                dgg.dialog.tip('只能输入' + length + '位的正整数!', obj, {tips: [3, '#000'], time: 3000});
                return false;
            } else {
                layer.closeAll("tips");
                return true;
            }
        }
    } else {
        if (!Number.test(objVal) || objVal.length > length) {
            dgg.dialog.tip('只能输入' + length + '位的正整数!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else {
            layer.closeAll("tips");
            return true;
        }
    }
}


/**
 * 约束输入  只能是正整数
 * @param obj
 * @param length 长度
 */
function checkInputLength(obj, length) {
    var $obj = obj instanceof jQuery ? obj : $(obj);
    var val = $obj.val();
    if (val) {
        if (!val.replace(/[^\d]/g, '') || val.length > length) {
            dgg.dialog.tip('只能输入' + length + '位的正整数!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        }
        val = val.replace(/[^\d]/g, '').substr(0, length);
        if (val.length > 1 && val.substr(0, 1) == 0) {
            dgg.dialog.tip('只能输入' + length + '位的正整数!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        }
    } else {
        dgg.dialog.tip('输入内容不能为空！', obj, {tips: [3, '#000'], time: 3000});
        return false;
    }
    return true;
}


/**
 * 判断  大于0 并且小于某个值 的浮点型
 * @param obj
 * @param float 小数位数 当传入 0 时验证整数
 * @param maxNum  最大值
 * @returns {boolean}
 */
function isFloatRangeSam(obj, float, maxNum) {
    var objVal = $(obj).val(),
        objFlat = objVal.indexOf("."),
        isFloat = /^\d+(\.\d+)?$/;
    if (objVal === "" || objVal == null) {
        layer.closeAll("tips");
        return true;
    } else if (!isFloat.test(objVal)) {
        dgg.dialog.tip('只能输入大于或等于零的数字!', obj, {tips: [3, '#000'], time: 3000});
        return false;
    } else if (float === 0) {//这里表示验证整数
        if (objFlat !== -1) {
            dgg.dialog.tip('只能输入整数!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else if (parseInt(objVal) > parseInt(maxNum)) {
            dgg.dialog.tip('只能输入小于' + maxNum + '的整数!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else {
            layer.closeAll("tips");
            return true;
        }
    } else if (float !== undefined && objFlat > 0) {
        var flo = objVal.toString().split(".")[1].length;
        if (flo > float) {
            dgg.dialog.tip('只能输入小数位' + float + '位以内的小数!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else if (parseFloat(objVal) > parseFloat(maxNum)) {
            dgg.dialog.tip('只能输入小于' + maxNum + '的数字!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else {
            layer.closeAll("tips");
            return true;
        }
    } else if (parseFloat(objVal) > parseFloat(maxNum)) {
        dgg.dialog.tip('只能输入小于' + maxNum + '的数字!', obj, {tips: [3, '#000'], time: 3000});
        return false;
    } else {
        layer.closeAll("tips");
        return true;
    }

}


/**
 * 判断大于0的浮点型
 * @param obj
 * @param float 小数位数
 * @param falg  是否为空
 * @param length  整数位数
 * @returns {boolean}
 */
function isFloatGteZeroByLength(obj, float, falg, length) {
    var objVal = $(obj).val(),
        objFlat = objVal.indexOf("."),
        isFloat = /^\d+(\.\d+)?$/;
    if (falg == false) {
        if (objVal == "" || objVal == null) {
            layer.closeAll("tips");
            return true;
        } else if (!isFloat.test(objVal)) {
            dgg.dialog.tip('只能输入大于零的数字!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else if (float != undefined) {
            var len = objVal.toString().split(".")[0].length;
            if (len > length) {
                dgg.dialog.tip('整数位数需小于' + length + '位数', obj, {tips: [3, '#000'], time: 3000});
                return false;
            } else {
                layer.closeAll("tips");
                return true;
            }
            if (objFlat > 0) {
                var flo = objVal.toString().split(".")[1].length
                if (flo > float) {
                    dgg.dialog.tip('只能输入小数位' + float + '位以内大于等于0的小数', obj, {tips: [3, '#000'], time: 3000});
                    return false;
                } else {
                    layer.closeAll("tips");
                    return true;
                }
            }

        } else {
            layer.closeAll("tips");
            return true;
        }
    } else {
        if (objVal == "" || objVal == null) {
            dgg.dialog.tip('输入内容不能为空', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else if (!isFloat.test(objVal)) {
            dgg.dialog.tip('只能输入大于零的数字!', obj, {tips: [3, '#000'], time: 3000});
            return false;
        } else if (float != undefined) {
            var len = objVal.toString().split(".")[0].length;
            if (len > length) {
                dgg.dialog.tip('整数位数需小于' + length + '位数', obj, {tips: [3, '#000'], time: 3000});
                return false;
            } else {
                layer.closeAll("tips");
                return true;
            }
            if (objFlat > 0) {
                var flo = objVal.toString().split(".")[1].length
                if (flo > float) {
                    dgg.dialog.tip('只能输入小数位' + float + '位以内大于等于0的小数', obj, {tips: [3, '#000'], time: 3000});
                    return false;
                } else {
                    layer.closeAll("tips");
                    return true;
                }
            }

        } else {
            layer.closeAll("tips");
            return true;
        }
    }
}

var isEmptyStorage = function isEmptyStorage() {
    console.log("storage_length >>> ", sessionStorage.length);
    for (var i = 0; i < sessionStorage.length; i++) {
        var key = sessionStorage.key(i);
        var value = sessionStorage[key];
        console.log(key, JSON.parse(value));
    }
}

// 特殊字符和长度
var isSymbolAndLength = function (obj, minNum, maxNum, errormsg) {
    minNum = !!minNum ? minNum : 1;
    maxNum = !!maxNum ? maxNum : 200;
    return isInLength(obj, minNum, maxNum) && isSymbol(obj, errormsg);
}

// 长度验证
// var isInLength = function (obj, minLength, maxLength, errormsg) {
//     return functions.isInLength.apply(functions, [obj, minLength, maxLength, erroeJson.size_error_msg.format(!!errormsg ? errormsg : '', minLength, maxLength)])
// }

// 特殊字符
var isSymbol = function (obj, errormsg) {
    return isRegularExp(obj, html_check, erroeJson.sc_error_msg.format(!!errormsg ? errormsg : ''));
}

// 特殊字符 ,允许输入小引号
var isSymbolNotQuotes = function (obj, errormsg) {
    return isRegularExp(obj, html_check_1, erroeJson.sc_error_msg.format(!!errormsg ? errormsg : ''));
}

// 自定义正则
var isRegularExp = function (obj, regexpmsg, errormsg) {
    return functions.isRegularExp.apply(functions, [true, obj, regexpmsg, errormsg])
};

// 区间验证
var isInterval = function (obj, minNum, maxNum, falg, errormsg) {
    return functions.isInterval.apply(functions, [obj, maxNum, minNum, falg, errormsg])
};

// 删除错误提示框
var removeTip = function (obj) {
    return functions.removeTip.apply(functions, obj)
};
var functions = {
    closeTips: function (obj) {
        $(obj).focus(function () {
            layer.closeAll("tips");
        });
        $(obj).change(function () {
            layer.closeAll("tips");
        });
    },
    removeTip: function (obj) {
        $(obj).next('.iconfont').remove();
        $(obj).removeClass("error-tips");
    },
    layerTips: function (tips, obj) {
        this.addTips(obj);
        obj = $(obj).next();
        layer.tips(tips, obj, {
            tipsMore: true,
            fixed: true,
            tips: [1, '#696e82'],
            offset: 't',
            skin: 'layer-tip',
            time: 3000,
            success: function (layero) {
                if (obj.parents('.layui-layer-content').length != 0) {
                    var par = $(obj).parent();
                    par.css('position', 'relative')
                    var _t = $(obj).position().top - 30 + 'px',
                        _l = $(obj).position().left + 10 + 'px';
                    var tipsHtm = layero[0];
                    var css = {
                        top: _t,
                        left: _l,
                        position: 'absolute'
                    };
                    obj.parent().append(tipsHtm)
                    par.find('.layui-layer-tips').css(css);
                    par.find('.layui-layer-tips .layui-layer-content').css('overflow', 'inherit');
                }
            }
        });
    },
    addTips: function (obj) {
        $(obj).next('.iconfont').remove();
        $(obj).addClass("error-tips");
        $(obj).after('<i class="iconfont icon-zhuyi-xian"></i>')
        this.closeTips(obj);
        return false;
    },
    isInLength: function (obj, minLength, maxLength, errormsg) {
        //var val = $(obj).val().replace(/(^\s*)|(\s*$)/g, ""),
        var val = $(obj).val(),
            objLength = !!val ? val.length : 0;
        if (objLength < minLength || objLength > maxLength) {
            if (objLength < minLength) {
                this.layerTips(!!errormsg ? errormsg : ("输入内容长度不能小于" + minLength), obj);
            }
            if (objLength > maxLength) {
                this.layerTips(!!errormsg ? errormsg : ("输入内容长度不能超过" + maxLength), obj);
            }
            return false;
        } else {
            this.removeTip(obj);
            return true;
        }
    },
    //传入自定义正则
    isRegularExp: function (isMatch, obj, regexpmsg, errormsg) {
        if (!!isMatch) {
            if (regexpmsg.test($(obj).val()) == true) {
                this.layerTips(errormsg, obj);
                return false;
            } else {
                this.removeTip(obj);
                return true;
            }
        } else {
            if (regexpmsg.test($(obj).val()) == false) {
                this.layerTips(errormsg, obj);
                return false;
            } else {
                this.removeTip(obj);
                return true;
            }
        }
    },
    //区间验证
    isInterval: function (obj, maxNum, minNum, falg, errormsg) {
        var objVal = $(obj).val();
        if (falg == false || falg == undefined) {
            if (objVal == "" || objVal == null) {
                this.removeTip(obj);
                return true;
            } else {
                if (!Num_check.test(objVal)) {
                    this.layerTips(errormsg, obj)
                    this.addTips(obj);
                    return false;
                } else if (objVal > parseInt(maxNum)) {
                    this.layerTips(errormsg, obj)
                    this.addTips(obj);
                    return false;
                } else if (objVal < parseFloat(minNum)) {
                    this.layerTips(errormsg, obj)
                    this.addTips(obj);
                    return false;
                } else {
                    this.removeTip(obj);
                    return true;
                }
            }
        } else {
            if (objVal == "" || objVal == null) {
                this.layerTips(errormsg, obj)
                this.addTips(obj);
                return false;
            } else {
                if (!Num_check.test(objVal)) {
                    this.layerTips(errormsg, obj)
                    this.addTips(obj);
                    return false;
                } else if (objVal > parseInt(maxNum)) {
                    this.layerTips(errormsg, obj)
                    this.addTips(obj);
                    return false;
                } else if (objVal < parseFloat(minNum)) {
                    this.layerTips(errormsg, obj)
                    this.addTips(obj);
                    return false;
                } else {
                    this.removeTip(obj);
                    return true;
                }
            }
        }
    },
    //自定义验证规则
    isValidate: function (obj, isPass, errormsg) {
        if (!!isPass) {
            this.removeTip(obj);
            return true;
        } else {
            this.layerTips(errormsg, obj)
            this.addTips(obj);
            return false;
        }
    }
};
/*
 显示错误信息 集合
 */
var erroeJson = {
    num_error_msg_1: "请输入数量",
    num_error_msg: "输入的数量不正确",
    price_error_msg: "请输入正确的单价",
    commodity_price: "金额只能输入1-7位,最多2位小数,大于1的正数",
    commodity_total_amount: "商品总价不合法 ,总价为1-7位 ,最多2位小数 ,大于1的正数",
    blank_order_total_amount: "订单金额为大于300 ,最大8位数的正整数",
    total_amount: "单价和数量乘积不能大于总金额",
    total_amount_1: "总价超过了商标单价",
    subject_error_msg: "请选择有效的主体信息",
    sc_error_msg: "{0}不能有特殊字符",
    size_error_msg: "{0}输入的长度只能在{1}-{2}之间",
    cannot_repeat_input_error_msg: "不能重复输入"
};
